package cn.jly.boot.mp.custom_actuator.endpoint;

import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Map;

/**
 * 自定义endpoint
 * http://localhost:8080/actuator/container
 *
 * @PackageName cn.jly.boot.mp.custom_actuator.endpoint
 * @ClassName MyEndpoint
 * @Description 自定义endpoint
 * @Author 姬岚洋
 * @Date 2021/1/24 下午 5:03
 */
@Component
@Endpoint(id = "container")
public class MyEndpoint {

    @ReadOperation
    public Map getEndpointInfo() {
        return Collections.singletonMap("info", "姬岚洋的endpoint");
    }

    @WriteOperation
    public void setEndpointInfo() {
        // 操作 cmd -> jconsole -> MBean -> spring boot -> Endpoint -> Container -> 操作
        System.out.println("MyEndpoint.setEndpointInfo");
    }

}
